/**
 * User: Phil
 * Date: 10/13/11
 * Time: 11:00 PM
 */

var DOMINION_CARDS = new Array();

//******************************************************
//DOMINION BASE SET KINGDOM CARDS
//******************************************************

//Cellar
var CELLAR = Card.extend({
	init: function() {
		this._super("Cellar", 2, 0, "cellar.jpg");

		this.types.push(CardTypes.ACTION);
		this.types.push(CardTypes.KINGDOM);

		//+1 Action
		var effect1 = new Effect(EffectTypes.ACTION, 1, EffectQuantityTypes.FIXED, 0);
		effect1.description = "+1 Action";
		effect1.targets.push(new EffectTarget(EffectTargetTypes.SELF));
		effect1.triggers.push(new EffectTrigger(EffectTriggerTypes.STATIC, 0));

		//Discard a card, draw a card
		var effect2 = new Effect(EffectTypes.CARD, 1, 0);
		effect2.description = "Discard any number of cards.  +1 Card per card discarded.";
		effect1.targets.push(new EffectTarget(EffectTargetTypes.SELF_DECK));
		effect1.triggers.push(new EffectTrigger(EffectTriggerTypes.DISCARD));

		this.effects.push(effect1);
		this.effects.push(effect2);
	}
});
DOMINION_CARDS.push(new CELLAR());

//Chapel
var CHAPEL = Card.extend({
	init: function() {
		this._super("Chapel", 2, 0, "chapel.jpg");

		this.types.push(CardTypes.ACTION);
		this.types.push(CardTypes.KINGDOM);

		//+1 Action
		var effect1 = new Effect(EffectTypes.TRASH, 4, EffectQuantityTypes.UP_TO, 0);
		effect1.description = "Trash up to 4 cards from your hand.";
		effect1.targets.push(new EffectTarget(EffectTargetTypes.SELF_HAND));
		effect1.triggers.push(new EffectTrigger(EffectTriggerTypes.STATIC, 0));

		this.effects.push(effect1);
	}
});
DOMINION_CARDS.push(new CHAPEL());

//Moat
var MOAT = Card.extend({
	init: function() {
		this._super("Moat", 2, 0, "moat.jpg");

		this.types.push(CardTypes.ACTION);
		this.types.push(CardTypes.REACTION);
		this.types.push(CardTypes.KINGDOM);

		//+2 Cards
		var effect1 = new Effect(EffectTypes.CARD, 2, EffectQuantityTypes.FIXED, 0);
		effect1.description = "+2 Cards";
		effect1.targets.push(new EffectTarget(EffectTargetTypes.SELF_HAND));
		effect1.triggers.push(new EffectTrigger(EffectTriggerTypes.STATIC, 0));

		//Block attack
		var effect2 = new Effect(EffectTypes.BLOCK, 2, EffectQuantityTypes.FIXED, 0);
		effect2.description = "When another player plays an Attack card, you may reveal this from your hand.  If you do, you are unaffected by that Attack.";
		effect2.targets.push(new EffectTarget(EffectTargetTypes.SELF));
		effect2.triggers.push(new EffectTrigger(EffectTriggerTypes.ATTACK, 0));

		this.effects.push(effect1);
		this.effects.push(effect2);
	}
});
DOMINION_CARDS.push(new MOAT());

//Chancellor
var CHANCELLOR = Card.extend({
	init: function() {
		this._super("Chancellor", 3, 0, "chancellor.jpg");

		this.types.push(CardTypes.ACTION);
		this.types.push(CardTypes.KINGDOM);

		//+2 Coins
		var effect1 = new Effect(EffectTypes.MONEY, 2, EffectQuantityTypes.FIXED, 0);
		effect1.description = "+2 Coins";
		effect1.targets.push(new EffectTarget(EffectTargetTypes.SELF));
		effect1.triggers.push(new EffectTrigger(EffectTriggerTypes.STATIC, 0));

		//Discard deck (optional)
		var effect2 = new Effect(EffectTypes.DISCARD, 2, EffectQuantityTypes.FIXED, 0);
		effect2.description = "You may immediately put your deck into your discard pile.";
		effect2.targets.push(new EffectTarget(EffectTargetTypes.SELF_DECK));    //Discard should affect deck, not hand
		effect2.triggers.push(new EffectTrigger(EffectTriggerTypes.OPTIONAL, 0));

		this.effects.push(effect1);
		this.effects.push(effect2);
	}
});
DOMINION_CARDS.push(new CHANCELLOR());

//Village
var VILLAGE = Card.extend({
	init: function() {
		this._super("Village", 3, 0, "village.jpg");

		this.types.push(CardTypes.ACTION);
		this.types.push(CardTypes.KINGDOM);

		//+1 Card
		var effect1 = new Effect(EffectTypes.CARD, 1, EffectQuantityTypes.FIXED, 0);
		effect1.description = "+1 Card";
		effect1.targets.push(new EffectTarget(EffectTargetTypes.SELF));
		effect1.triggers.push(new EffectTrigger(EffectTriggerTypes.STATIC, 0));

		//+2 Actions
		var effect2 = new Effect(EffectTypes.ACTION, 2, EffectQuantityTypes.FIXED, 0);
		effect2.description = "+2 Actions";
		effect2.targets.push(new EffectTarget(EffectTargetTypes.SELF));
		effect2.triggers.push(new EffectTrigger(EffectTriggerTypes.STATIC, 0));

		this.effects.push(effect1);
		this.effects.push(effect2);
	}
});
DOMINION_CARDS.push(new VILLAGE());

//Woodcutter
var WOODCUTTER = Card.extend({
	init: function() {
		this._super("Woodcutter", 3, 0, "woodcutter.jpg");

		this.types.push(CardTypes.ACTION);
		this.types.push(CardTypes.KINGDOM);

		//+1 Buy
		var effect1 = new Effect(EffectTypes.BUY, 1, EffectQuantityTypes.FIXED, 0);
		effect1.description = "+1 Buy";
		effect1.targets.push(new EffectTarget(EffectTargetTypes.SELF));
		effect1.triggers.push(new EffectTrigger(EffectTriggerTypes.STATIC, 0));

		//+2 Coins
		var effect2 = new Effect(EffectTypes.MONEY, 2, EffectQuantityTypes.FIXED, 0);
		effect2.description = "+2 Coins";
		effect2.targets.push(new EffectTarget(EffectTargetTypes.SELF));
		effect2.triggers.push(new EffectTrigger(EffectTriggerTypes.STATIC, 0));

		this.effects.push(effect1);
		this.effects.push(effect2);
	}
});
DOMINION_CARDS.push(new WOODCUTTER());

//Workshop
var WORKSHOP = Card.extend({
	init: function() {
		this._super("Workshop", 3, 0, "workshop.jpg");

		this.types.push(CardTypes.ACTION);
		this.types.push(CardTypes.KINGDOM);

		//Gain card
		var effect1 = new Effect(EffectTypes.GAIN_CARD, 1, EffectQuantityTypes.FIXED, 0);
		effect1.description = "Gain a card costing up to 4 Coins.";
		effect1.targets.push(new EffectTarget(EffectTargetTypes.SELF));
		effect1.triggers.push(new EffectTrigger(EffectTriggerTypes.STATIC, 0));
		effect1.constraints.push(new EffectConstraint(EffectConstraintTypes.COSTS_UP_TO, 4));

		this.effects.push(effect1);
	}
});
DOMINION_CARDS.push(new WORKSHOP());

//Bureaucrat
var BUREAUCRAT = Card.extend({
	init: function() {
		this._super("Bureaucrat", 4, 0, "bureaucrat.jpg");

		this.types.push(CardTypes.ACTION);
		this.types.push(CardTypes.ATTACK);
		this.types.push(CardTypes.KINGDOM);

		//Gain a Silver card, put to top of deck
		var effect1 = new Effect(EffectTypes.GAIN_CARD, 1, EffectQuantityTypes.FIXED, 0);
		effect1.description = "Gain a silver card; put it on top of your deck.";
		effect1.targets.push(new EffectTarget(EffectTargetTypes.SELF_DECK));
		effect1.triggers.push(new EffectTrigger(EffectTriggerTypes.STATIC, 0));

		//All players topdeck a Victory card or reveal a hand with no Victory cards
		var effect2 = new Effect(EffectTypes.TOPDECK_CARD, 1, EffectQuantityTypes.FIXED, 0);
		effect2.description = "Each other player reveals a Victory card from his hand and puts it on his deck (or reveals a hand with no Victory cards).";
		effect2.targets.push(new EffectTarget(EffectTargetTypes.ALL_OPPONENTS));
		effect2.triggers.push(new EffectTrigger(EffectTriggerTypes.STATIC, 0));
		effect2.constraints.push(new EffectConstraint(EffectConstraintTypes.CARD_TYPE, CardTypes.VICTORY));

		this.effects.push(effect1);
		this.effects.push(effect2);
	}
});
DOMINION_CARDS.push(new BUREAUCRAT());

//Feast
var FEAST = Card.extend({
	init: function() {
		this._super("Feast", 4, 0, "feast.jpg");

		this.types.push(CardTypes.ACTION);
		this.types.push(CardTypes.KINGDOM);

		//Trash Feast
		var effect1 = new Effect(EffectTypes.TRASH, 1, EffectQuantityTypes.FIXED, 0);
		effect1.description = "Trash this this.";
		effect1.targets.push(new EffectTarget(EffectTargetTypes.THIS_CARD));
		effect1.triggers.push(new EffectTrigger(EffectTriggerTypes.STATIC, 0));

		//Gain card worth up to 5 coins
		var effect2 = new Effect(EffectTypes.GAIN_CARD, 1, EffectQuantityTypes.FIXED, 0);
		effect2.description = "Gain a card costing up to 5 coins.";
		effect2.targets.push(new EffectTarget(EffectTargetTypes.SELF_HAND));
		effect2.triggers.push(new EffectTrigger(EffectTriggerTypes.STATIC, 0));
		effect2.constraints.push(new EffectConstraint(EffectConstraintTypes.COSTS_UP_TO, 5));

		this.effects.push(effect1);
	}
});
DOMINION_CARDS.push(new FEAST());

//Gardens
var GARDENS = Card.extend({
	init: function() {
		this._super("Gardens", 4, 0, "gardens.jpg");

		this.types.push(CardTypes.ACTION);
		this.types.push(CardTypes.VICTORY);
		this.types.push(CardTypes.KINGDOM);

		//Worth one Victory for every 10 cards in your deck (rounded down).
		var effect1 = new Effect(EffectTypes.VICTORY, 1, EffectQuantityTypes.FIXED, 0);
		effect1.description = "Worth one Victory for every 10 cards in your deck (rounded down).";
		effect1.targets.push(new EffectTarget(EffectTargetTypes.SELF));
		effect1.triggers.push(new EffectTrigger(EffectTriggerTypes.STATIC, 0));

		//Gain card worth up to 5 coins
		var effect2 = new Effect(EffectTypes.GAIN_CARD, 1, EffectQuantityTypes.FIXED, 0);
		effect2.description = "Gain a card costing up to 5 coins.";
		effect2.targets.push(new EffectTarget(EffectTargetTypes.SELF_HAND));
		effect2.triggers.push(new EffectTrigger(EffectTriggerTypes.STATIC, 0));
		effect2.constraints.push(new EffectConstraint(EffectConstraintTypes.COSTS_UP_TO, 5));

		effect1.subEffects.push(effect2);

		this.effects.push(effect1);
	}
});
DOMINION_CARDS.push(new GARDENS());

//******************************************************
//DOMINION BASE SET TREASURES
//******************************************************

//Copper
var COPPER = Card.extend({
	init: function() {
		this._super("Copper", 0, 0, "copper.jpg");
		this.quantity = 60;

		this.types.push(CardTypes.TREASURE);

		//+1 Money
		var effect1 = new Effect(EffectTypes.MONEY, 1, EffectQuantityTypes.FIXED, 0);
		effect1.description = "$1";
		effect1.targets.push(new EffectTarget(EffectTargetTypes.SELF));
		effect1.triggers.push(new EffectTrigger(EffectTriggerTypes.STATIC, 0));

		this.effects.push(effect1);
	}
});
DOMINION_CARDS.push(new COPPER());

//Silver
var SILVER = Card.extend({
	init: function() {
		this._super("Silver", 3, 0, "silver.jpg");
		this.quantity = 40;

		this.types.push(CardTypes.TREASURE);

		//+1 Money
		var effect1 = new Effect(EffectTypes.MONEY, 2, EffectQuantityTypes.FIXED, 0);
		effect1.description = "$2";
		effect1.targets.push(new EffectTarget(EffectTargetTypes.SELF));
		effect1.triggers.push(new EffectTrigger(EffectTriggerTypes.STATIC, 0));

		this.effects.push(effect1);
	}
});
DOMINION_CARDS.push(new SILVER());

//Gold
var GOLD = Card.extend({
	init: function() {
		this._super("Gold", 6, 0, "gold.jpg");
		this.quantity = 30;

		this.types.push(CardTypes.TREASURE);

		//+1 Money
		var effect1 = new Effect(EffectTypes.MONEY, 3, EffectQuantityTypes.FIXED, 0);
		effect1.description = "$3";
		effect1.targets.push(new EffectTarget(EffectTargetTypes.SELF));
		effect1.triggers.push(new EffectTrigger(EffectTriggerTypes.STATIC, 0));

		this.effects.push(effect1);
	}
});
DOMINION_CARDS.push(new GOLD());


//******************************************************
//DOMINION BASE SET VICTORY CARDS
//******************************************************
//Estate
var ESTATE = Card.extend({
	init: function() {
		this._super("Estate", 2, 0, "estate.jpg");
		this.quantity = 24;

		this.types.push(CardTypes.VICTORY);

		//+1 Victory Points
		var effect1 = new Effect(EffectTypes.VICTORY, 1, EffectQuantityTypes.FIXED, 0);
		effect1.description = "1 Victory Point";
		effect1.targets.push(new EffectTarget(EffectTargetTypes.SELF));
		effect1.triggers.push(new EffectTrigger(EffectTriggerTypes.STATIC, 0));

		this.effects.push(effect1);
	}
});
DOMINION_CARDS.push(new ESTATE());

//Duchy
var DUCHY = Card.extend({
	init: function() {
		this._super("Duchy", 5, 0, "duchy.jpg");
		this.quantity = 12;

		this.types.push(CardTypes.VICTORY);

		//+3 Victory Points
		var effect1 = new Effect(EffectTypes.VICTORY, 3, EffectQuantityTypes.FIXED, 0);
		effect1.description = "3 Victory Points";
		effect1.targets.push(new EffectTarget(EffectTargetTypes.SELF));
		effect1.triggers.push(new EffectTrigger(EffectTriggerTypes.STATIC, 0));

		this.effects.push(effect1);
	}
});
DOMINION_CARDS.push(new DUCHY());

//Province
var PROVINCE = Card.extend({
	init: function() {
		this._super("Province", 8, 0, "province.jpg");
		this.quantity = 12;

		this.types.push(CardTypes.VICTORY);

		//+6 Victory Points
		var effect1 = new Effect(EffectTypes.VICTORY, 6, EffectQuantityTypes.FIXED, 0);
		effect1.description = "6 Victory Points";
		effect1.targets.push(new EffectTarget(EffectTargetTypes.SELF));
		effect1.triggers.push(new EffectTrigger(EffectTriggerTypes.STATIC, 0));

		this.effects.push(effect1);
	}
});
DOMINION_CARDS.push(new PROVINCE());